package com.example.demo.auto.entityhelp;

import com.beiding.businessplatform.data.BeHelp;
import com.beiding.businessplatform.data.BeHolder;
import com.beiding.businessplatform.data.Holder;
import com.beiding.businessplatform.data.HolderMap;
import com.example.demo.auto.entity.ABe;
import com.example.demo.auto.entity.BBe;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ABeHelp extends BeHelp<ABe> {

    public HolderMap createBeHolder(BeHolder holder) {

        Map<String, Holder> holderMap = new HashMap<>();

        holderMap.put("id",
                new Holder() {
                    @Override
                    public Object get() {
                        return ((BeHolder<ABe>) holder).make().getId();
                    }

                    @Override
                    public void set(Object value) {
                        ((BeHolder<ABe>) holder).make().setId((String) value);
                    }
                }
        );

        holderMap.put("name",
                new Holder() {
                    @Override
                    public Object get() {
                        return ((BeHolder<ABe>) holder).make().getName();
                    }

                    @Override
                    public void set(Object value) {
                        ((BeHolder<ABe>) holder).make().setName((String) value);
                    }
                }
        );

        holderMap.put("bs",
                new Holder() {
                    @Override
                    public Object get() {
                        return ((BeHolder<ABe>) holder).make().getBs();
                    }

                    @Override
                    public void set(Object value) {
                        ((BeHolder<ABe>) holder).make().setBs((List<BBe>) value);
                    }
                }
        );

        return new HolderMap(holderMap);
    }

}
